<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ .Title }}</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <style>
        body{padding-top:50px}
        #mdFileList table{width:100%}
        #mdFileList table caption{text-align:center;font-size:20px}
        #mdFileList table tr{height:30px}
        #mdFileList table tr.tr-addFile button{border:0}
        #mdFileList table tr th{height:30px;line-height:30px;text-align:center}
        #mdFileList table tr td{height:30px;line-height:30px}
        #mdFileList table tr td.text-right{padding-right:10px}
        #mdFileList table tr td.sort{width:70px}
        #mdFileList table tr td img.file-dir{width:16px;height:16px;margin-left:10px}
        #mdFileList table tr td a{height:30px;line-height:30px;padding-left:10px}
        #mdFileList table tr td .md-status{cursor:pointer;color:#337ab7}
        #mdFileList table tr td input{height:30px;line-height:30px;border:0;width:100%;text-align:right;padding-right:10px;background-color:#EEEEEE}
        #addFileBtn,#dir-addBtn{width:100%;height:100%;margin:0 auto;border:0;color:#337ab7;background-color:#FFF}
        #mdFileList table tr td select{width:100%;height:100%;border:0}
    </style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">{{ .Title }}</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="/admin">List</a></li>
                <li><a href="/admin-add">Add</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div id="mdFileList">
        <table border="1">
            <caption>markdown 文件列表</caption>
            <tr>
                <th>编号</th>
                <th>文件名</th>
                <th>文件大小</th>
                <th>最后编辑时间</th>
                <th>排序</th>
                <th>重命名</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
            {{range .FileList }}
            <tr data-id="{{ .Id }}">
                <td class="text-center">{{ .Id }}</td>
                {{if eq .IsCategory 1}}
                <td colspan="3">
                    <img src="/images/dir.png" class="file-dir">{{.CategoryName}}
                </td>
                {{else}}
                <td><a href="/read/{{.Id}}" target="_blank">{{ .MdTitle }}</a></td>
                <td class="text-right">{{ .MdFileSize }}</td>
                <td class="text-center">{{ .CreateTime | TimeZone2Str }}</td>
                {{end}}
                <td class="sort">
                    <input type="number" name="sort" value="{{.SortNum}}" size="5" placeholder="排序"/>
                </td>
                <td>
                    <input type="text" name="fileName" value="{{ .MdTitle }}" placeholder="重命名"/>
                </td>
                <td class="text-center">
                    {{if eq .IsCategory 1}}
                    -
                    {{else}}
                    <a href="/admin/edit/{{ .Id }}" target="_blank">编辑</a>
                    {{end}}
                </td>
                <td class="text-center">
                    {{if eq .IsShow 1 }}<span class="md-status">Show</span>
                    {{else}}<span class="md-status">Hide</span>
                    {{end}}
                </td>
            </tr>
            {{range .ChildList}}
            <tr>
                <td class="text-center">{{ .Id }}</td>
                <td>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="/read/{{.Id}}" target="_blank">{{ .MdTitle }}</a>
                </td>
                <td class="text-right">{{ .MdFileSize }}</td>
                <td class="text-center">{{ .CreateTime | TimeZone2Str }}</td>
                <td class="sort">
                    <input type="number" name="sort" value="{{.SortNum}}" size="5" placeholder="排序"/>
                </td>
                <td>
                    <input type="text" name="fileName" value="{{ .MdTitle }}" placeholder="重命名"/>
                </td>
                <td class="text-center">
                    <a href="/admin/edit/{{ .Id }}" target="_blank">编辑</a>
                </td>
                <td class="text-center">
                    {{if eq .IsShow 1 }}<span class="md-status">Show</span>
                    {{else}}<span class="md-status">Hide</span>
                    {{end}}
                </td>
            </tr>
            {{end}}
            {{end}}

            <tr>
                <td colspan="8"></td>
            </tr>

            <tr class="tr-addFile">
                <td colspan="2" class="text-right">【添加文件】选择文件所在的目录：</td>
                <td colspan="2" class="text-right">
                    <select id="categoryId">
                        <option value="/">/</option>
                        {{range .FileList }}{{if eq .IsCategory 1}}
                        <option value="{{.Id}}">/{{.CategoryName}}</option>
                        {{end}}{{end}}
                    </select>
                </td>
                <td colspan="1">
                    <input type="number" id="sort-number" required value="0" placeholder="排序值">
                </td>
                <td colspan="1">
                    <input type="text" id="cons-title" required placeholder="新文件名,不可重复">
                </td>
                <td colspan="2">
                    <button type="button" id="addFileBtn">点击添加文件</button>
                </td>
            </tr>

            <tr class="tr-addDir">
                <td colspan="2" class="text-right">【添加目录】</td>
                <td colspan="2" class="text-right">目录都在根下面，不支持二级目录</td>
                <td colspan="1">
                    <input type="number" id="dir-sortNumber" required value="0" placeholder="排序值"/>
                </td>
                <td colspan="1">
                    <input type="text" id="dir-newName" required placeholder="新目录名,不可重复"/>
                </td>
                <td colspan="2">
                    <button type="button" id="dir-addBtn">点击添加目录</button>
                </td>
            </tr>
        </table>
    </div>

</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/admin-list.js?_=v1"></script>
</body>
</html>